/**
 * 
 */
package org.myontology.users;

import java.util.StringTokenizer;

import org.myontology.controller.AbstractAction;
import org.myontology.controller.AttributeHolder;
import org.myontology.controller.SesameSession;

/**
 * @author hacklm
 *
 */
public class ImportUsersAction extends AbstractAction {

	private SesameSession session;
	
	/* (non-Javadoc)
	 * @see org.myontology.controller.Action#execute(org.myontology.controller.AttributeHolder)
	 */
	public void execute(AttributeHolder attributes) throws Exception {
		String sent = attributes.getRequestParameter("sent");
		if (sent!=null) {
			String values = attributes.getRequestParameter("importValue");
			String pwd = attributes.getRequestParameter("pwd");
			if (pwd.equals("siorpaes")) {
				StringTokenizer userT = new StringTokenizer(values,";");
				while (userT.hasMoreElements()) {
					String userS = userT.nextElement().toString().trim();
					StringTokenizer valueT = new StringTokenizer(userS,",");
					String userName = valueT.nextElement().toString();
					String pass = valueT.nextElement().toString();
					String email = valueT.nextElement().toString();
					
					User u = new User();
					u.id.addValue(userName);
					u.pwd.addValue(pass);
					u.email.addValue(email);
					session.update(u);
					
				}
			}
		}
	}

}
